﻿#include "pch.h"
#if _QG_ENABLE_WIDGET
#include "qgp/qgach.h"
#include "qgp/qgaud.h"
#include "qgp/qguwgs.h"

//////////////////////////////////////////////////////////////////////////
// 분리자
KIMPL_SUBCLASS(qwDivide, "WidgetDivide");

qwDivide::qwDivide(qgWidgetType type)
	: super_type(type)
{
	_insts.fill = true;
}

void qwDivide::OnInitialize()
{
	_res[0] = _shed->GetResource(QGWELM_DIVIDE_0);
	_res[1] = _shed->GetResource(QGWELM_DIVIDE_1);
	_res[2] = _shed->GetResource(QGWELM_DIVIDE_2);
	_res[3] = _shed->GetResource(QGWELM_DIVIDE_3);
}

bool qwDivide::OnUpdate(float adv)
{
	BuildBound();

	if (NeedRefresh())
		ResetRefresh();

	return true;
}

void qwDivide::OnDraw()
{
	if (CanFill())
	{
		tpl::Rect rt = _client;

		if (_horiz)
		{
			for (kint i = 0; i < _count; i++)
			{
				rt.right = rt.left + _thick;
				_shed->DrawFillRect(rt, _res[i]);

				rt.left += _thick;
			}
		}
		else
		{
			for (kint i = 0; i < _count; i++)
			{
				rt.bottom = rt.top + _thick;
				_shed->DrawFillRect(rt, _res[i]);

				rt.top += _thick;
			}
		}
	}

	qwCtrl::OnDraw();
}

#endif	// _QG_ENABLE_WIDGET
